#include "bodyMotionState.h"

using namespace sde;

BodyMotionState::BodyMotionState(Object* _object, btTransform transform) :
    btDefaultMotionState(transform),
    object(_object) {
}

void BodyMotionState::getWorldTransform(btTransform& transform) const {
    btDefaultMotionState::getWorldTransform(transform);
}

void BodyMotionState::setWorldTransform(const btTransform& transform) {
    btDefaultMotionState::setWorldTransform(transform);
    if (object) {
        btQuaternion rotation = m_graphicsWorldTrans.getRotation();
        btVector3 position = m_graphicsWorldTrans.getOrigin();
        object->setVar("rotation",PhysicsServer::BulletQuaternionToQuaternion(rotation));
        object->setVar("position",PhysicsServer::BulletVectorToVector(position));
    }
}
